<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width,initial-scale=1.0">
    <style>
        #div1 {
          display: flex;
          align-items: center;
        }
        .icon-expand {
            width: 20px;
            height: 20px;
            background: url('../assets/arrow.png') no-repeat;
            background-size: 100% 100%;
            display: inline-block;
        }
        #div1:hover .icon-expand {
            transform: rotate(180deg);
            transition: cubic-bezier(0.075, 0.82, 0.165, 1);
        }
    </style>
  </head>
  <body>
    <div id="app">
        <div id="div1">展开<i class="icon-expand"></i></div>
    </div>
    <script>
      console.log("start")
      async function f() {
        console.log("f")
        await new Promise((res,rej)=>{
          let t = 1000;
          setTimeout(()=>{
            console.log(`setTimeout ${t}ms`);
            res(777);
          }, t);
          console.log(`promise ${t}`);
        }).then((result)=>{
          console.log(`result ${result}`)
        });
        console.log("f-2")
      }

      async function f0() {
        console.log("f0");
        // 在这儿取消await 或者加上await，分析结果。
        await f();
        console.log("f0-2");
      }

      async function f1() {
        console.log("f1")
        // 加了await， 会等到f0()的”f0-2"输出之后再输出f1-2；没加await，
        await f0();
        console.log("f1-2")
      }
      async function f2() {
        console.log("f2")
        await f1();
        console.log("f2-2")
      }

      f2();
      console.log("end")
    </script>
  </body>
</html>
